﻿using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class 数据访问控件_GridVide套DataList :  GridVidw套Datalist
{

    protected void Page_Load(object sender, EventArgs e)
    {
        BindData();
    }


    void BindData()
    {
     
        GridView1.DataSource =  OleDbDataSet("select * from [lx]");
        DataBind();
    }





    /// <summary>
    /// GRIDView 数据帮定时
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ccc(object sender, GridViewRowEventArgs e)
    {
        ///这行代码 是说 如果这行是数据帮定行的话
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label ll = ((Label)(e.Row.Cells[0].FindControl("Label1")));//得到行
            
            //开始邦定dataList 动态邦定 DataList
            DataList MyDL = ((DataList)e.Row.Cells[0].FindControl("DataList1"));
            MyDL.DataSource = OleDbDataSet("select top 50 * from [test] where  FileExtname='"+ll.Text+"'");
            MyDL.DataBind();
            


        }
    }

}



public class GridVidw套Datalist:System.Web.UI.Page
{ 
      public DataSet OleDbDataSet(string sql)
    {
        string Connstr = "Provider=MicroSoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("../App_Data/db1.mdb");//联接字符串
        OleDbConnection MyConn = new OleDbConnection(Connstr);

        OleDbDataAdapter NetPagerDa = new OleDbDataAdapter(sql,MyConn);
        NetPagerDa.SelectCommand.CommandType = CommandType.Text;//选择执行命令的方式
        DataSet MyDs = new DataSet();

        NetPagerDa.Fill(MyDs,"FyNetPager");
        NetPagerDa=null;

        return MyDs;

    }
}